﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;


namespace SignalrDemo.Hubs
{

    public class PushHub : Hub
    {
        /// <summary>
        /// 添加分组
        /// </summary>
        /// <param name="group"></param>
        public void AddToGroup(string group)
        {
            this.Groups.Add(Context.ConnectionId, group);
            //return this.Clients.All.Count;
        }

        public override System.Threading.Tasks.Task OnConnected()
        {
            Clients.Group("server").notices("新增ID:" + Context.ConnectionId);
            return base.OnConnected();
        }
        public override System.Threading.Tasks.Task OnDisconnected()
        {
            Clients.Group("server").notices("断开连接:" + Context.ConnectionId);
            return base.OnDisconnected();
        }
        public override System.Threading.Tasks.Task OnReconnected()
        {
            Clients.Group("server").notices("重新连接:" + Context.ConnectionId);
            return base.OnReconnected();
        }


    }
}